home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / src / Viewperf5.1src.lha / Viewperf5.1 / viewperf / plyF.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-04  |  12.8 KB  |  361 lines

  1. #ifdef WIN32
  2. #include <windows.h>
  3. #endif
  4.  
  5. #include <GL/gl.h>
  6. #include "viewperf.h"
  7. #include "vpDefine.h"
  8.  
  9. void FUNCTION(struct ThreadBlock *tb) 
  10. {
  11.   int polyi,verti;
  12.   int numverts;
  13.   int polycount = tb->np;
  14.   int *vertindex;
  15.   GLenum mode = tb->mode;
  16. #ifdef BATCH
  17.   int groupi;
  18.   int batchi;
  19.   int leftoveri;
  20.   int batchcount = tb->batchnum;
  21.   int groupcount = tb->batchgroups;
  22.   int leftovercount = tb->batchleftovers;
  23. #endif
  24. #ifdef EXTERNAL
  25.   GLenum capability = tb->capability;
  26.   void (*lExternfunc)(GLenum) = tb->externfunc;
  27. #endif
  28. #ifdef BY_TWO
  29.   int *startvertindex;
  30. #endif
  31.   struct vector *pvert=tb->vert;
  32.   struct plygon *pply=tb->ply;
  33.  
  34. #ifndef FUNCTION_CALLS
  35. #ifdef WIN32
  36.   void (APIENTRY *glVertex3fvP)(const GLfloat *);
  37. #else
  38.   void (*glVertex3fvP)(const GLfloat *);
  39. #endif
  40. #endif
  41.   
  42. #if defined(FACET_NORM) || defined(VERT_NORM)
  43.   struct vector *pvnorm=tb->vnorm;
  44. #ifndef FUNCTION_CALLS
  45. #ifdef WIN32
  46.   void (APIENTRY *glNormal3fvP)(const GLfloat *);
  47. #else
  48.   void (*glNormal3fvP)(const GLfloat *);
  49. #endif
  50. #endif /* ifndef FUNCTION_CALLS */
  51. #endif
  52.   
  53. #if defined(FACET_COLOR) || defined(VERT_COLOR)
  54.   struct colorvector *pvcolor=tb->vcolor;
  55. #ifndef FUNCTION_CALLS
  56. #ifdef WIN32
  57.   void (APIENTRY *glColorP)(const GLfloat *);
  58. #else
  59.   void (*glColorP)(const GLfloat *);
  60. #endif
  61. #endif  /* ifndef FUNCTION_CALLS */
  62. #endif
  63.   
  64. #ifdef TEXTURE
  65.   struct vector *ptexture=tb->texture;  
  66. #ifndef FUNCTION_CALLS
  67. #ifdef WIN32
  68.   void (APIENTRY *glTexCoord2fvP)(const GLfloat *);
  69. #else
  70.   void (*glTexCoord2fvP)(const GLfloat *);
  71. #endif
  72. #endif  /* ifndef FUNCTION_CALLS */
  73. #endif
  74.   
  75. #ifndef FUNCTION_CALLS
  76. #ifdef  TEXTURE
  77.   glTexCoord2fvP = glTexCoord2fv;
  78. #endif
  79. #if defined(FACET_COLOR) || defined(VERT_COLOR)
  80.   glColorP = tb->ColorP;
  81. #endif
  82. #if defined(FACET_NORM) || defined(VERT_NORM)
  83.   glNormal3fvP = glNormal3fv;
  84. #endif
  85.   glVertex3fvP = glVertex3fv;
  86. #endif /* ifndef FUNCTION_CALLS */
  87.  
  88.   
  89. #ifdef BATCH
  90.       polyi = polycount;
  91.       for(groupi=groupcount-1;groupi>=0;groupi--) 
  92.     {
  93.       glBegin(mode);
  94.       for(batchi=batchcount-1;batchi>=0;batchi--) 
  95.         {
  96.           polyi--;
  97. #else
  98.       for(polyi=polycount-1;polyi>=0;polyi--) 
  99.      {
  100. #endif
  101.        numverts = pply[polyi].numverts;
  102.        vertindex = pply[polyi].index;
  103. #ifdef BY_TWO
  104.        startvertindex = vertindex;
  105. #endif
  106. #ifdef EXTERNAL
  107.        lExternfunc(capability);
  108. #endif
  109. #if    defined(FACET_COLOR) && !defined(FUNCTION_CALLS)
  110.        (*glColorP)((const GLfloat *) (pvcolor + *vertindex));
  111. #elif  defined(FACET_COLOR) && defined(FUNCTION_CALLS) && !defined(COLOR4)
  112.        glColor3fv((const GLfloat *) (pvcolor + *vertindex));
  113. #elif  defined(FACET_COLOR) && defined(FUNCTION_CALLS) && defined(COLOR4)
  114.        glColor4fv((const GLfloat *) (pvcolor + *vertindex));
  115. #endif
  116. #if    defined(FACET_NORM) && !defined(FUNCTION_CALLS)
  117.        (*glNormal3fvP)((const GLfloat *) (pvnorm + *vertindex));
  118. #elif  defined(FACET_NORM) && defined(FUNCTION_CALLS)
  119.        glNormal3fv((const GLfloat *) (pvnorm + *vertindex));
  120. #endif
  121. #ifndef BATCH
  122.        glBegin(mode);
  123. #endif
  124. #ifdef BY_TWO
  125.        for(verti=numverts-2;verti>=0;verti--) 
  126.          {
  127. #else
  128.        for(verti=numverts-1;verti>=0;verti--) 
  129.          {
  130. #endif
  131. #if    defined(VERT_COLOR) && !defined(FUNCTION_CALLS)
  132.            (*glColorP)((const GLfloat *) (pvcolor + *vertindex));
  133. #elif  defined(VERT_COLOR) && defined(FUNCTION_CALLS) && !defined(COLOR4)
  134.            glColor3fv((const GLfloat *) (pvcolor + *vertindex));
  135. #elif  defined(VERT_COLOR) && defined(FUNCTION_CALLS) && defined(COLOR4)
  136.            glColor4fv((const GLfloat *) (pvcolor + *vertindex));
  137. #endif
  138. #if    defined(TEXTURE) && !defined(FUNCTION_CALLS)
  139.            (*glTexCoord2fvP)((const GLfloat *) (ptexture + *vertindex));
  140. #elif  defined(TEXTURE) && defined(FUNCTION_CALLS)
  141.            glTexCoord2fv((const GLfloat *) (ptexture + *vertindex));
  142. #endif
  143. #if    defined(VERT_NORM)  &&  !defined(FUNCTION_CALLS)
  144.            (*glNormal3fvP)((const GLfloat *) (pvnorm + *vertindex));
  145. #elif  defined(VERT_NORM)  &&  defined(FUNCTION_CALLS)
  146.            glNormal3fv((const GLfloat *) (pvnorm + *vertindex));
  147. #endif
  148. #ifdef  FUNCTION_CALLS
  149.            glVertex3fv((const GLfloat *) (pvert + *vertindex));
  150. #else
  151.            (*glVertex3fvP)((const GLfloat *) (pvert + *vertindex));
  152. #endif
  153. #ifdef BY_TWO
  154.   #if    defined(VERT_COLOR) && !defined(FUNCTION_CALLS)
  155.            (*glColorP)((const GLfloat *) (pvcolor + *(vertindex+1)));
  156.   #elif  defined(VERT_COLOR) && defined(FUNCTION_CALLS) && !defined(COLOR4)
  157.            glColor3fv((const GLfloat *) (pvcolor + *(vertindex+1)));
  158.   #elif  defined(VERT_COLOR) && defined(FUNCTION_CALLS) && defined(COLOR4)
  159.            glColor4fv((const GLfloat *) (pvcolor + *(vertindex+1)));
  160.   #endif
  161.   #if    defined(TEXTURE) && !defined(FUNCTION_CALLS)
  162.            (*glTexCoord2fvP)((const GLfloat *) (ptexture + *(vertindex+1)));
  163.   #elif  defined(TEXTURE) &&  defined(FUNCTION_CALLS)
  164.            glTexCoord2fv((const GLfloat *) (ptexture + *(vertindex+1)));
  165.   #endif
  166.   #if    defined(VERT_NORM)  &&  !defined(FUNCTION_CALLS)
  167.            (*glNormal3fvP)((const GLfloat *) (pvnorm + *(vertindex+1)));
  168.   #elif  defined(VERT_NORM)  &&  defined(FUNCTION_CALLS)
  169.            glNormal3fv((const GLfloat *) (pvnorm + *(vertindex+1)));
  170.   #endif
  171.   #ifdef  FUNCTION_CALLS
  172.            glVertex3fv((const GLfloat *) (pvert + *(vertindex+1)));
  173.   #else
  174.            (*glVertex3fvP)((const GLfloat *) (pvert + *(vertindex+1)));
  175.   #endif
  176. #endif
  177.            ++vertindex;
  178.          }
  179. #ifdef BY_TWO
  180.   #if    defined(VERT_COLOR) && !defined(FUNCTION_CALLS)
  181.        (*glColorP)((const GLfloat *) (pvcolor + *vertindex));
  182.   #elif  defined(VERT_COLOR) &&  defined(FUNCTION_CALLS) && !defined(COLOR4)
  183.        glColor3fv((const GLfloat *) (pvcolor + *vertindex));
  184.   #elif  defined(VERT_COLOR) &&  defined(FUNCTION_CALLS) &&  defined(COLOR4)
  185.        glColor4fv((const GLfloat *) (pvcolor + *vertindex));
  186.   #endif
  187.   #if    defined(TEXTURE)  &&  !defined(FUNCTION_CALLS)
  188.        (*glTexCoord2fvP)((const GLfloat *) (ptexture + *vertindex));
  189.   #elif  defined(TEXTURE)  &&   defined(FUNCTION_CALLS)
  190.        glTexCoord2fv((const GLfloat *) (ptexture + *vertindex));
  191.   #endif
  192.   #if    defined(VERT_NORM)  &&  !defined(FUNCTION_CALLS)
  193.        (*glNormal3fvP)((const GLfloat *) (pvnorm + *vertindex));
  194.   #elif  defined(VERT_NORM)  &&   defined(FUNCTION_CALLS)
  195.        glNormal3fv((const GLfloat *) (pvnorm + *vertindex));
  196.   #endif
  197.   #ifdef FUNCTION_CALLS
  198.        glVertex3fv((const GLfloat *) (pvert + *vertindex));
  199.   #else
  200.        (*glVertex3fvP)((const GLfloat *) (pvert + *vertindex));
  201.   #endif
  202.   #if    defined(VERT_COLOR) && !defined(FUNCTION_CALLS)
  203.        (*glColorP)((const GLfloat *) (pvcolor + *startvertindex));
  204.   #elif  defined(VERT_COLOR) &&  defined(FUNCTION_CALLS) && !defined(COLOR4)
  205.        glColor3fv((const GLfloat *) (pvcolor + *startvertindex));
  206.   #elif  defined(VERT_COLOR) &&  defined(FUNCTION_CALLS) &&  defined(COLOR4)
  207.        glColor4fv((const GLfloat *) (pvcolor + *startvertindex));
  208.   #endif
  209.   #if    defined(TEXTURE) && !defined(FUNCTION_CALLS)
  210.        (*glTexCoord2fvP)((const GLfloat *) (ptexture + *startvertindex));
  211.   #elif  defined(TEXTURE) &&  defined(FUNCTION_CALLS)
  212.        glTexCoord2fv((const GLfloat *) (ptexture + *startvertindex));
  213.   #endif
  214.   #if    defined(VERT_NORM) && !defined(FUNCTION_CALLS)
  215.        (*glNormal3fvP)((const GLfloat *) (pvnorm + *startvertindex));
  216.   #elif  defined(VERT_NORM) &&  defined(FUNCTION_CALLS)
  217.        glNormal3fv((const GLfloat *) (pvnorm + *startvertindex));
  218.   #endif
  219.   #ifdef FUNCTION_CALLS
  220.        glVertex3fv((const GLfloat *) (pvert + *startvertindex));
  221.   #else
  222.        (*glVertex3fvP)((const GLfloat *) (pvert + *startvertindex));
  223.   #endif
  224. #endif
  225. #ifndef BATCH
  226.        glEnd();
  227. #endif
  228.      }
  229. #ifdef BATCH
  230.           glEnd();
  231.         }
  232.       glBegin(mode);
  233.       for(leftoveri=leftovercount-1;leftoveri>=0;leftoveri--) 
  234.         {
  235.           polyi--;
  236.           numverts = pply[polyi].numverts;
  237.           vertindex = pply[polyi].index;
  238.   #ifdef BY_TWO
  239.           startvertindex = vertindex;
  240.   #endif
  241.   #if    defined(FACET_COLOR) && !defined(FUNCTION_CALLS)
  242.           (*glColorP)((const GLfloat *) (pvcolor + *vertindex));
  243.   #elif  defined(FACET_COLOR) &&  defined(FUNCTION_CALLS) && !defined(COLOR4)
  244.           glColor3fv((const GLfloat *) (pvcolor + *vertindex));
  245.   #elif  defined(FACET_COLOR) &&  defined(FUNCTION_CALLS) &&  defined(COLOR4)
  246.           glColor4fv((const GLfloat *) (pvcolor + *vertindex));
  247.   #endif
  248.   #if    defined(FACET_NORM) && !defined(FUNCTION_CALLS)
  249.           (*glNormal3fvP)((const GLfloat *) (pvnorm + *vertindex));
  250.   #elif  defined(FACET_NORM) &&  defined(FUNCTION_CALLS)
  251.           glNormal3fv((const GLfloat *) (pvnorm + *vertindex));
  252.   #endif
  253.   #ifdef BY_TWO
  254.           for(verti=numverts-2;verti>=0;verti--) 
  255.         {
  256.   #else
  257.               for(verti=numverts-1;verti>=0;verti--) 
  258.         {
  259.   #endif
  260.   #if    defined(VERT_COLOR) && !defined(FUNCTION_CALLS)
  261.           (*glColorP)((const GLfloat *) (pvcolor + *vertindex));
  262.   #elif  defined(VERT_COLOR) &&  defined(FUNCTION_CALLS) && !defined(COLOR4)
  263.           glColor3fv((const GLfloat *) (pvcolor + *vertindex));
  264.   #elif  defined(VERT_COLOR) &&  defined(FUNCTION_CALLS) &&  defined(COLOR4)
  265.           glColor4fv((const GLfloat *) (pvcolor + *vertindex));
  266.   #endif
  267.   #if    defined(TEXTURE) && !defined(FUNCTION_CALLS)
  268.           (*glTexCoord2fvP)((const GLfloat *) (ptexture + *vertindex));
  269.   #elif  defined(TEXTURE) &&  defined(FUNCTION_CALLS)
  270.           glTexCoord2fv((const GLfloat *) (ptexture + *vertindex));
  271.   #endif
  272.   #if    defined(VERT_NORM) && !defined(FUNCTION_CALLS)
  273.           (*glNormal3fvP)((const GLfloat *) (pvnorm + *vertindex));
  274.   #elif  defined(VERT_NORM) &&  defined(FUNCTION_CALLS)
  275.           glNormal3fv((const GLfloat *) (pvnorm + *vertindex));
  276.   #endif
  277.   #ifdef FUNCTION_CALLS
  278.           glVertex3fv((const GLfloat *) (pvert + *vertindex));
  279.   #else
  280.           (*glVertex3fvP)((const GLfloat *) (pvert + *vertindex));
  281.   #endif
  282.   #ifdef BY_TWO
  283.     #if    defined(VERT_COLOR) && !defined(FUNCTION_CALLS)
  284.           (*glColorP)((const GLfloat *) (pvcolor + *(vertindex+1)));
  285.     #elif  defined(VERT_COLOR) &&  defined(FUNCTION_CALLS) && !defined(COLOR4)
  286.           glColor3fv((const GLfloat *) (pvcolor + *(vertindex+1)));
  287.     #elif  defined(VERT_COLOR) &&  defined(FUNCTION_CALLS) &&  defined(COLOR4)
  288.           glColor4fv((const GLfloat *) (pvcolor + *(vertindex+1)));
  289.     #endif
  290.     #if    defined(TEXTURE) && !defined(FUNCTION_CALLS)
  291.           (*glTexCoord2fvP)((const GLfloat *) (ptexture + *(vertindex+1)));
  292.     #elif  defined(TEXTURE) &&  defined(FUNCTION_CALLS)
  293.           glTexCoord2fv((const GLfloat *) (ptexture + *(vertindex+1)));
  294.     #endif
  295.     #if    defined(VERT_NORM) && !defined(FUNCTION_CALLS)
  296.           (*glNormal3fvP)((const GLfloat *) (pvnorm + *(vertindex+1)));
  297.     #elif  defined(VERT_NORM) &&  defined(FUNCTION_CALLS)
  298.           glNormal3fv((const GLfloat *) (pvnorm + *(vertindex+1)));
  299.     #endif
  300.     #ifdef FUNCTION_CALLS
  301.           glVertex3fv((const GLfloat *) (pvert + *(vertindex+1)));
  302.     #else
  303.           (*glVertex3fvP)((const GLfloat *) (pvert + *(vertindex+1)));
  304.     #endif
  305.   #endif
  306.           ++vertindex;
  307.         }
  308.   #ifdef BY_TWO
  309.     #if    defined(VERT_COLOR) && !defined(FUNCTION_CALLS)
  310.           (*glColorP)((const GLfloat *) (pvcolor + *vertindex));
  311.     #elif  defined(VERT_COLOR) &&  defined(FUNCTION_CALLS) && !defined(COLOR4)
  312.           glColor3fv((const GLfloat *) (pvcolor + *vertindex));
  313.     #elif  defined(VERT_COLOR) &&  defined(FUNCTION_CALLS) &&  defined(COLOR4)
  314.           glColor4fv((const GLfloat *) (pvcolor + *vertindex));
  315.     #endif
  316.     #if    defined(TEXTURE) && !defined(FUNCTION_CALLS)
  317.           (*glTexCoord2fvP)((const GLfloat *) (ptexture + *vertindex));
  318.     #elif  defined(TEXTURE) &&  defined(FUNCTION_CALLS)
  319.           glTexCoord2fv((const GLfloat *) (ptexture + *vertindex));
  320.     #endif
  321.     #if    defined(VERT_NORM) && !defined(FUNCTION_CALLS)
  322.           (*glNormal3fvP)((const GLfloat *) (pvnorm + *vertindex));
  323.     #elif  defined(VERT_NORM) &&  defined(FUNCTION_CALLS)
  324.           glNormal3fv((const GLfloat *) (pvnorm + *vertindex));
  325.     #endif
  326.     #ifdef FUNCTION_CALLS
  327.           glVertex3fv((const GLfloat *) (pvert + *vertindex));
  328.     #else
  329.           (*glVertex3fvP)((const GLfloat *) (pvert + *vertindex));
  330.     #endif
  331.  
  332.     #if    defined(VERT_COLOR) && !defined(FUNCTION_CALLS)
  333.           (*glColorP)((const GLfloat *) (pvcolor + *startvertindex));
  334.     #elif  defined(VERT_COLOR) &&  defined(FUNCTION_CALLS) && !defined(COLOR4)
  335.           glColor3fv((const GLfloat *) (pvcolor + *startvertindex));
  336.     #elif  defined(VERT_COLOR) &&  defined(FUNCTION_CALLS) &&  defined(COLOR4)
  337.           glColor4fv((const GLfloat *) (pvcolor + *startvertindex));
  338.     #endif
  339.     #if    defined(TEXTURE) && !defined(FUNCTION_CALLS) 
  340.           (*glTexCoord2fvP)((const GLfloat *) (ptexture + *startvertindex));
  341.     #elif  defined(TEXTURE) &&  defined(FUNCTION_CALLS) 
  342.           glTexCoord2fv((const GLfloat *) (ptexture + *startvertindex));
  343.     #endif
  344.     #if    defined(VERT_NORM) && !defined(FUNCTION_CALLS)
  345.           (*glNormal3fvP)((const GLfloat *) (pvnorm + *startvertindex));
  346.     #elif  defined(VERT_NORM) &&  defined(FUNCTION_CALLS)
  347.           glNormal3fv((const GLfloat *) (pvnorm + *startvertindex));
  348.     #endif
  349.     #ifdef FUNCTION_CALLS
  350.           glVertex3fv((const GLfloat *) (pvert + *startvertindex));
  351.     #else
  352.           (*glVertex3fvP)((const GLfloat *) (pvert + *startvertindex));
  353.     #endif
  354.   #endif
  355.  
  356.         }
  357.           glEnd();
  358. #endif
  359.  
  360. }
  361.